<?php include("conn.php") ?>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <?php include("public/cssjs.php");?>
    <link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
    <link href="static/city/css/city-picker.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="page-container">
    <?php

    $con=new Mysql();
    $sql = "select * from products where id ='".$_GET["id"]."'";
    $id = $_GET["id"];
    $rs =$con->getRow($sql);
    if(!$rs)
    {
        OutErrorBack("信息不存在!");
    }
    else {

        ?>
        <form action="" method="post" class="form form-horizontal" id="form-member-add" name="form1">
            <input type="hidden" name="proid" id="proid" value="<?php echo $id; ?>" />
            <div id="tab-system" class="HuiTab">
                <div class="tabBar cl">
                    <span>产品基本信息</span>
                    <span>产品SEO</span>
                    <span>图片设置</span>
                    <span>参数设置</span>
                    <span>商品详情</span>
                    <span>商品尺寸</span>
                    <span>组装和说明</span>
                </div>
                <div class="tabCon">
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否精选：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <div class="radio-box">
                                <input name="is_hot" type="radio" value="1" id="is_hot-1" <?php if($rs["is_hot"]==1){echo "checked";}?>>
                                <label for="is_hot-1">是</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" id="is_hot-2" value="0" name="is_hot" <?php if($rs["is_hot"]==0){echo "checked";}?>>
                                <label for="is_hot-2">否</label>
                            </div>
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否特价：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <div class="radio-box">
                                <input name="is_tejia" type="radio" value="1" id="is_tejia-1" <?php if($rs["is_tejia"]==1){echo "checked";}?>>
                                <label for="is_hot-1">是</label>
                            </div>
                            <div class="radio-box">
                                <input type="radio" id="is_tejia-2" value="0" name="is_tejia" <?php if($rs["is_tejia"]==1){echo "checked";}?>>
                                <label for="is_hot-2">否</label>
                            </div>
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>产品标题：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <input type="text" class="input-text" value="<?php echo $rs["title"];?>" placeholder="产品名称" id="title" name="title">
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">简略描述：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <input type="text" class="input-text" value="<?php echo $rs["title_f"];?>" placeholder="简略概要" id="title_f"
                                   name="title_f">
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>所属分类：</label>
                        <div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select name="utype" id="utype" class="select">
					<? ShowSelect(0, "newscata_product", $rs["type"], 6, true) ?>
				</select>
				</span></div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">排序值：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <input type="text" class="input-text" value="<?php echo $rs["px"];?>" placeholder="数值越高越靠前" id="px" name="px">
                        </div>
                    </div>
                    <div class="row cl displays">
                        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>原价：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <input type="text" name="ys_s_price" id="ys_s_price" placeholder="原价" value="<?php echo $rs["ys_s_price"];?>"
                                   class="input-text" style="width:20%">
                            元
                        </div>
                    </div>
                    <div class="row cl displays">
                        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>现价：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <input type="text" name="ys_e_price" id="ys_e_price" placeholder="现价" value="<?php echo $rs["ys_e_price"];?>"
                                   class="input-text" style="width:20%">
                            元
                        </div>
                    </div>
                </div>
                <div class="tabCon">
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">网页关键字：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <input type="text" name="adtitle" id="adtitle" placeholder="网页标题" value="<?php echo $rs["adtitle"];?>"
                                   class="input-text">
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">网页关键字：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <input type="text" name="adkeyword" id="adkeyword" placeholder="多个关键字用英文逗号隔开，限10个关键字"
                                   value="<?php echo $rs["adkeyword"];?>" class="input-text">
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">网页描述：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <textarea name="adescription" id="adescription" cols="" rows="" class="textarea"
                                      placeholder="说点什么...最少输入10个字符" datatype="*10-100" dragonfly="true"
                                      nullmsg="备注不能为空！" onKeyUp="$.Huitextarealength(this,200)"><?php echo $rs["adescription"];?></textarea>
                            <p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
                        </div>
                    </div>

                </div>
                <div class="tabCon">

                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>缩略图568*509px：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <iframe
                                    src="../pic/images_UP.php?bd=a1_img&form=form1" name="key" width="448"
                                    height="30" marginheight="0" scrolling="No" frameborder="0" id="key">IE
                            </iframe>
                            <input type="text" name="a1_img" id="a1_img" value="<?php echo $rs["pic"];?>" class="input-text" size="60">
                        </div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>相册：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <iframe
                                    src="../pic/images_UP2.php?bd=a2_img&form=form1" name="key" width="448"
                                    height="30" marginheight="0" scrolling="No" frameborder="0" id="key">IE
                            </iframe>
                            <input type="text" name="a2_img" id="a2_img" class="input-text" size="60"  value="<?php echo $rs["picall"];?>">
                            <input type="hidden" name="a2_img_old" id="a2_img_old" class="input-text" size="60"  value="<?php echo $rs["picall"];?>">
                        </div>
                    </div>
                </div>
                <div class="tabCon">

                    <?php
                    $sql="select * from d_attr where id=".$rs["id"];
                    $rsa=$conn->getAll($sql);
                    foreach($rsa as $k=>$rs){
                        echo $rs["attrtype"];

                    }
                    ?>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">分类名称：</label>
                        <div class="formControls col-xs-8 col-sm-9"><input type="text" name="attrtype" id="attrtype"
                                                                           class="input-text" style="width: 40%"></div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">分类参数： </label>
                        <div class="formControls col-xs-8 col-sm-9"><input type="text" name="attr" id="attr"
                                                                           class="input-text" style="width: 40%"></div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">参数图片： </label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <iframe
                                    src="../pic/images_UP.php?bd=a3_img&form=form1" name="key" width="448"
                                    height="30" marginheight="0" scrolling="No" frameborder="0" id="key">IE
                            </iframe>
                            <input type="text" name="a3_img" id="a3_img" class="input-text" size="60"></div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">参数价格： </label>
                        <div class="formControls col-xs-8 col-sm-9"><input type="text" name="pmoney" id="pmoney"
                                                                           class="input-text" style="width: 40%"></div>
                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">价格选择：</label>
                        <div class="formControls col-xs-8 col-sm-9"><select class="city-select" name="istype"
                                                                            id="istype">
                                <option value="0">价格不变</option>
                                <option value="1">价格叠加</option>
                                <option value="2">使用全价</option>
                            </select> <input type="button" name="btnadd" id="btnadd" class="btn btn-primary radius"
                                             value="添加参数"></div>
                    </div>
                    <div class="row cl">
                        <div class="formControls col-xs-8 col-sm-9"><label class="form-label col-xs-4 col-sm-2"></label>
                        </div>
                    </div>
                </div>
                <div class="tabCon">


                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">商品详情：</label>
                        <div class="formControls col-xs-8 col-sm-9">

                            <textarea id="editor" style="width:100%;height:400px;" name="myContent"><?php echo $rs["content"];?></textarea>
                            <script type="text/javascript">
                                var editor = new baidu.editor.ui.Editor();
                                editor.render("editor");
                            </script>
                        </div>
                    </div>
                </div>
                <div class="tabCon">
                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">商品尺寸：</label>
                        <div class="formControls col-xs-8 col-sm-9">

                            <textarea id="editor2" style="width:100%;height:400px;" name="myContent2"><?php echo $rs["content2"];?></textarea>
                            <script type="text/javascript">
                                var editor = new baidu.editor.ui.Editor();
                                editor.render("editor2");
                            </script>
                        </div>
                    </div>
                </div>
                <div class="tabCon">

                    <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">组装说明：</label>
                        <div class="formControls col-xs-8 col-sm-9">

                            <textarea id="editor1" style="width:100%;height:400px;" name="myContent1"><?php echo $rs["content1"];?></textarea>
                            <script type="text/javascript">
                                var editor1 = new baidu.editor.ui.Editor();
                                editor.render("editor1");
                            </script>
                        </div>
                    </div>

                </div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                    <button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存并提交
                    </button>

                    <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
                </div>
            </div>
        </form>
        <?php
    }
    ?>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/h-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/h-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="lib/webuploader/0.1.5/webuploader.min.js"></script>
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>



<script type="text/javascript">
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        $("#tab-system").Huitab({
            index:0
        });
        $("#btn-star").click(function(){
            var files=$("#file-2").val();
            $.get("json/upload.php?files="+files,function(data){
                alert(data);
            })
        })
    });
</script>
<script type="text/javascript">
    $(function(){
        var ue = UE.getEditor('editor');
        var ue1 = UE.getEditor('editor1');
        var ue2 = UE.getEditor('editor2');
        $("#form-member-add").validate({
            rules:{
                title:{
                    required:true
                }

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var pid=$("#proid").val();
                var type=$("#utype").val();
                var title=$("#title").val();
                var title_f=$("#title_f").val();
                var content=$('textarea[name="myContent"]').val();
                var content1=$('textarea[name="myContent1"]').val();
                var content2=$('textarea[name="myContent2"]').val();
                var adtitle=$("#adtitle").val();
                var adkeyword=$("#adkeyword").val();
                var adescription=$("#adescription").val();
                var px=$("#px").val();
                var ys_s_price=$("#ys_s_price").val();
                var ys_e_price=$("#ys_e_price").val();
                var pic1=$("#a1_img").val();
                var pic2=$("#a2_img").val();
                var is_hot=$('input[name="is_hot"]').val();
                var is_tejia=$('input[name="is_tejia"]').val();
                $.ajax({
                    type:"POST",
                    url:"json/products.php" ,
                    data:{'type':type,'title':title,'title_f':title_f,'content':content,'content1':content1,'content2':content2,'adtitle':adtitle,'adkeyword':adkeyword,'adescription':adescription,'px':px,'is_hot':is_hot,'is_tejia':is_tejia,'pic1':pic1,'pic2':pic2,'ys_s_price':ys_s_price,'ys_e_price':ys_e_price,'id':pid,'Type':'edit'},
                    datatype: "json",
                    success:function(data){
                        if(data==1){
                            layer.msg('添加成功!',{icon:1,time:1000});
                            var index=parent.layer.getFrameIndex(window.name);
                            window.parent.location.reload();
                            parent.layer.close(index);
                        }else{
                            alert(data);
                            //layer.msg('系统错误error!'+data,{icon:1,time:1000});
                        }


                    }
                });


            }
        });
        //alert("enter:"+UE.getEditor('editor').getContent());
    });
    $(function(){

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        $("#btnadd").click(function(){
            var attrtype=$("#attrtype").val();
            var attr=$("#attr").val();
            var pic=$("#a3_img").val();
            var pmoney=$("#pmoney").val();
            var istype=$("#istype").val();
            var shopid=0;
            var pid=$("#proid").val();
            alert(123);
            $.ajax({
                type: "POST",
                url: "json/proattr.php",
                data: {
                    'attrtype': attrtype,
                    'attr': attr,
                    'pic': pic,
                    'pmoney': pmoney,
                    'istype': istype,
                    'shopid': shopid,
                    'pid': pid,
                    'Type': 'add'
                },
                datatype: "json",
                success: function (data) {
                    alert(data);
                }
            })



        })


    });



</script>

</body>
</html>
